Software Development
Control Structures in C++
Control Structures in C++: Range-based for Loops
Control Structures in C++: Using Conditional Control Structures

Control Structures in C++: Range-based for Loops

Course Number:
it_cpcspfdj_02_enus
Lesson Objectives

Control Structures in C++: Range-based for Loops

  • discover the key concepts covered in this course
  • iterate over arrays using for loops
  • create string arrays and use break and continue
  • create multidimensional arrays and iterate over them
  • recall the offerings of the standard template library
  • access out-of-bound elements and create iterators
  • search for an element in a vector through templates
  • use the cend(), rend(), and crend() functions
  • build and debug code
  • debug code using a build
  • walk through code using a debugger
  • contrast strings and string references
  • use maps and range-based for loops
  • summarize the key concepts covered in this course

Overview/Description
One of the many differences between modern C++ and classic C++ is the presence of range-based for loops. These were added to the standard in C++11 and allow for loops to iterate easily over a container and reduce the risk of off-by-one errors. They also eliminate the need for an integer index variable to index into a container. Start this course by reviewing how for loops work to iterate over arrays. Create arrays with different numbers of dimensions and iterate over the dimensions using nested for loops. Discover how to use containers from the standard template library to experiment with maps and vectors. Explore the use of the cbegin(), cend(), rbegin(), rend(), crbegin(), and crend() functions. Finally, use range-based for loops and explore the use of the debugger in this context. You will also note the important differences between value type loop variables in for loops and reference type variables.

Target

Prerequisites: none

Control Structures in C++: Using Conditional Control Structures

Course Number:
it_cpcspfdj_01_enus
Lesson Objectives

Control Structures in C++: Using Conditional Control Structures

  • discover the key concepts covered in this course
  • outline different control structures in C++
  • modify the flow of a program with if-blocks
  • overload operators and use them in if statements
  • create vectors and check whether they are empty
  • iterate over vectors and search for a specific element
  • create variables in if-block signatures
  • chain relational checks using logical operators
  • create enums and switch statements
  • create variables in switch statements scope and switch statements on characters
  • create switch statements on strings
  • create switch statements on variables created with function calls
  • create switch statements on strings through enums
  • summarize the key concepts covered in this course

Overview/Description
Control structures in C++ are syntactically very similar to those in C, but with some important differences. This course will help you learn to use control structures in C++ and better understand how they differ from those in C. You will start this course by going over the control structures available in C++. You will then move on to working with vectors and iterators over vectors, which are important parts of the standard template library. Finally, you will work with switch statements and learn some tips and tricks related to working with cases based on strings. Upon completion, you'll be able to use variables in the condition of an if-block to restrict its scope, and use switch statements with hash functions and the STL map object to switch based on the values of a string.

Target

Prerequisites: none

Close Chat Live